<template>
    <div class="temp">
        <div class="mui-content" style="background-color:#fff">
            <ul class="mui-table-view mui-grid-view">
                <li class="mui-table-view-cell mui-media mui-col-xs-6" v-for="item in list">
                    <router-link v-bind='{to:"/goods/goodsinfo/"+item.id}'>
                        <img class="mui-media-object" :src="item.img_url">
                        <div class="mui-media-body">{{item.title}}</div>
                        <div class="info">
                            <div class="info-t"><span>￥{{item.market_price}}</span><span>￥{{item.sell_price}}</span></div>
                            <div class="info-b"><span>热销中</span><span>库存：{{item.stock_quantity}}</span></div>
                        </div>
                    </router-link>
                </li>
            </ul>
        </div>

    </div>
</template>

<script>
    import {Toast} from 'mint-ui';
    import common from "../../kits/common.js";
    export default{
        data(){
            return {
                list:[]
            }
        },
        created(){
            this.getList();
        },
        methods:{
            getList(){
                const url = common.apidomain + "/api/getgoods?pageindex=1";
                this.$http.get(url).then((response) => {
                    let body = response.body;
                    if(body.status != 0){
                        Toast({
                            message: body.message,
                            position: 'bottom',
                            duration: 5000
                        });
                        return;
                    }
                    this.list = body.message;
                })
            }
        }
    }
</script>

<style scoped>
    .mui-content ul {
        padding: 0px;
    }
    .mui-content li:nth-child(2n+1) {
        border-right: 1px solid rgba(0,0,0,.2);
    }
    .mui-content li {
        border-bottom: 1px solid rgba(0,0,0,.2);
    }
    .mui-table-view.mui-grid-view .mui-table-view-cell {
        padding: 5px;
        margin: 0;
    }
    .mui-table-view.mui-grid-view .mui-table-view-cell>a {
        padding: 0;
        margin: 0;
    }
    .mui-content li .info {
        width: 100%;
        height: 50px;
        background-color: rgba(0,0,0,.1);
        margin-top: 10px;
        position: relative;
        font-size: 14px;
    }
    .mui-content li .info-t{
        width: 100%;
        text-align: left;
        color: red;
    }
    .mui-content li .info-t span:last-child {
        text-decoration: line-through;
        color: #a2a4a4;
        margin-left: 5px;
    }
    .mui-content li .info-b {
        width: 100%;
        position: absolute;
        bottom: 2px;
        padding: 0 3px;
    }
    .mui-content li .info-b span:first-child {
        float: left;
    }
    .mui-content li .info-b span:last-child {
        float: right;
    }
    .mui-table-view.mui-grid-view .mui-table-view-cell .mui-media-body {
        color: #26d0ff;
        font-size: 16px;
        line-height: 1.2em;
        height: 1.2em;
    }

</style>